-
Notifications
You must be signed in to change notification settings - Fork 0
TyKind
in GlobalAlloc
s
#84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! And makes sense to add the type information at this stage.
Two points to consider changing, however:
- The PR proposes to store
TyKind
(which should always beRigidTy
BTW) but the extraction generally (and the semantics so far) instead stores and uses theTy
IDs to refer to a type. By storingRigidTy
here we have to engage in decoding theRigidTy
to something useful. - The "thing that's useful" already exists in the code as
TypeInfo
, so we would be duplicating the decoder.
I'd suggest we just store the Ty
ID with the alloc instead of the RigidTy
and use the lookups into the existing types
table and existing decoder code. The change would be relatively easy: At the call site for collect_alloc
we can pass in the ty
and get the resp. TyKind
within collect_alloc
.
src/printer.rs
Outdated
if debug_enabled() { | ||
println!( | ||
"DEBUG: called collect_alloc: {:?}:{:?}:{:?}", | ||
val, pointed_kind, global_alloc | ||
); | ||
} | ||
entry.or_insert(AllocInfo::Memory(alloc.clone())); // TODO: include pointed_kind.clone().unwrap() ? | ||
entry.or_insert((kind.unwrap(), AllocInfo::Memory(alloc.clone()))); // TODO: include pointed_kind.clone().unwrap() ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entry.or_insert((kind.unwrap(), AllocInfo::Memory(alloc.clone()))); // TODO: include pointed_kind.clone().unwrap() ? | |
entry.or_insert((kind.unwrap(), AllocInfo::Memory(alloc.clone()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree! Amending now!
{ | ||
"kind": "ReErased" | ||
}, | ||
31, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the problem that fails the golden tests in CI, the IDs stored here are unstable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, but you should probably wait to merge this one until you have a branch ready on KMIR that uses this and can confirm it's populating the <globals>
cell correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
GlobalAlloc
s need to be decoded to their types, this can be done easier by preprocessing the python (maybe in the future in the repo). But for the python to preprocess it will go easier with theTy
available in the JSON.AllocInfo
to be a struct that contains theGlobalAlloc
information, originally it was a enum that was a duplicate ofstable_mir::mir::alloc::GlobalAlloc
. The struct helps with the JSON as the field names come through.TyKind
from the allocs and provs to work withTy
collect_alloc
also takes aTy
as a parameter instead of aTyKind
nowAllocMap
is now collects theTy
also